package com.spt.springbootzhsx.service.suggest.Get_Result_7;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;
import java.util.Iterator;

public class Result_Reducer extends Reducer<ResultBean, Text, Text, NullWritable> {
    @Override
    protected void reduce(ResultBean key, Iterable<Text> values, Context context) throws IOException, InterruptedException {
        Iterator<Text> iter = values.iterator();

        //集合的第一个元素
        Text res = iter.next();

        //如果集合没有下一个元素，直接写出
        if (!iter.hasNext()) {
            context.write(res, NullWritable.get());
        }

    }
}
